package com.example.administrator.liveapp.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.CountDownTimer;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.administrator.liveapp.ApplicationUtils;
import com.example.administrator.liveapp.R;
import com.example.administrator.liveapp.Xutils3.MyCallBack;
import com.example.administrator.liveapp.Xutils3.XUtils;
import com.example.administrator.liveapp.bean.ActivityDetailsBean;
import com.example.administrator.liveapp.utils.AppUrl;
import com.example.administrator.liveapp.utils.TimeChangeUtil;
import com.google.gson.Gson;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;

import org.json.JSONException;
import org.json.JSONObject;
import org.xutils.common.util.LogUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 活动详情activity
 */

public class BookingDetailsPage extends AppCompatActivity implements View.OnClickListener {

    private String activityId;//单个报名Id
    private String consumerId;//用户id
    private String timeStatus;//活动状态
    private ActivityDetailsBean bean;
    private TextView title;//活动标题
    private TextView activity_content;//活动简介
    private RadioButton views;//浏览量
    private TextView activity_money;//票价
    private TextView text_number;//报名人数
    private TextView activity_Author;//主讲人
    private TextView activity_Place;//活动地址
    private View loadView;//loding页面（加载页）
    private TextView The_countdown;//LiveDetailsPage
    private Button appointment_button;//立即报名
    private TextView need_pay;//是否在免费组
    private TextView activity_address;//活动详细地址
    private TextView activity_time;//活动开始时间
    private ImageView activity_image;
    private RadioButton best;
    private ImageView action_return;//返回
    private ImageView share;//分享

    private int mDisplayDays;//天
    private int mDisplayHours;//时
    private int mDisplayMinutes;//分
    private int mDisplaySeconds;//秒
    private long time;//系统当前时间
    private long countdownTime;

    private LinearLayout shengyu;
    private TextView xiahua;

    //支付
    private PopupWindow mPopWindow;
    private Button payButton;
    private ImageView zhifubao;
    private ImageView weixin;
    private RelativeLayout zfb;
    private RelativeLayout wx;
    private IWXAPI mIwxapi;
    private TextView money;
    /**
     * 倒计时:
     */
    private CountDownTimer timer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ApplicationUtils applicationUtils = new ApplicationUtils();
        applicationUtils.addActivity(this);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("action.refreshFriend");
        registerReceiver(mRefreshBroadcastReceiver, intentFilter);
        initView();
        setData();
    }

    private BroadcastReceiver mRefreshBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals("action.refreshFriend")) {
                setData();
            }
        }
    };

    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mRefreshBroadcastReceiver);
    }

    public void initView() {
        setContentView(R.layout.booking_detailspage);
        appointment_button = (Button) findViewById(R.id.appointment_button);
        activity_content = (TextView) findViewById(R.id.activity_content);
        activity_Author = (TextView) findViewById(R.id.activity_Author);
        activity_money = (TextView) findViewById(R.id.activity_money);
        activity_Place = (TextView) findViewById(R.id.activity_Place);
        text_number = (TextView) findViewById(R.id.text_number);
        The_countdown = (TextView) findViewById(R.id.The_countdown);
        need_pay = (TextView) findViewById(R.id.need_pay);
        activity_address = (TextView) findViewById(R.id.activity_address);
        activity_time = (TextView) findViewById(R.id.activity_time);
        activity_image = (ImageView) findViewById(R.id.activity_image);
        shengyu = (LinearLayout) findViewById(R.id.shengyu);
        xiahua = (TextView) findViewById(R.id.xiahua);
        best = (RadioButton) findViewById(R.id.best);
        loadView = findViewById(R.id.loadView);
        views = (RadioButton) findViewById(R.id.views);
        title = (TextView) findViewById(R.id.title);
        action_return = (ImageView) findViewById(R.id.action_return);
        share = (ImageView) findViewById(R.id.share);
        share.setOnClickListener(this);
        action_return.setOnClickListener(this);
        appointment_button.setOnClickListener(this);
        best.setOnClickListener(this);
        findViewById(R.id.activity_Place).setOnClickListener(this);
        Intent intent = getIntent();
        activityId = intent.getStringExtra("activityId");
        if (ApplicationUtils.getInstance().loginBean != null) {
            consumerId = ApplicationUtils.getInstance().loginBean.getConsumerid();
        }
//        timeStatus = intent.getStringExtra("timeStatus");
    }


    private String Days, Hours, Minutes, Seconds;//倒计时显示格式

    public void setData() {
        String url = AppUrl.URLS + AppUrl.ActivityDetailsURL;
        Map<String, String> map = new HashMap<>();
        map.put("activityId", activityId);
        if (consumerId != null) {
            map.put("consumerId", consumerId);
        }
        XUtils.Get(url, map, new MyCallBack<String>() {
            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                Log.e("result", result);
                Gson gson = new Gson();
                bean = gson.fromJson(result, ActivityDetailsBean.class);
                best.setText(bean.getActivity().getActivitybestcount() + "");
                if (bean.getActivity().getActivityBestStatus() == 0) {
                    Drawable rightDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.praise_w, null);
                    rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
                    best.setCompoundDrawables(rightDrawable, null, null, null);
                } else {
                    Drawable rightDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.praise, null);
                    rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
                    best.setCompoundDrawables(rightDrawable, null, null, null);
                }
                title.setText(bean.getActivity().getActivitytitle());
                activity_time.setText(TimeChangeUtil.getStrTimes(bean.getActivity().getActivitystatime()));
                activity_content.setText(bean.getActivity().getActivitydescribe());
                views.setText(bean.getActivity().getActivityviewcount());
                if (!bean.getActivity().getActivityprice().equals("0.00")) {
                    activity_money.setText(bean.getActivity().getActivityprice());
                    if (bean.getActivity().getNeedPay().equals("0")) {
                        need_pay.setVisibility(View.VISIBLE);
                    } else if (bean.getActivity().getNeedPay().equals("1")) {
                        activity_money.setText("¥ " + bean.getActivity().getActivityprice());
                    } else {
                        activity_money.setText("¥ " + bean.getActivity().getActivityprice());
                    }
                } else {
                    activity_money.setText("免费");
                }
                activity_Place.setText(bean.getActivity().getHost());
                activity_address.setText(bean.getActivity().getActivityplace());
                if (bean.getActivity().getActivityimgurl() != null && !bean.getActivity().getActivityimgurl().equals("")) {
                    String Url = bean.getActivity().getActivityimgurl();
                    String ImageUrl = Url.substring(1, Url.indexOf("|"));
                    Glide.with(BookingDetailsPage.this)
                            .load(AppUrl.URLS + ImageUrl)
                            .into(activity_image);
                }
                text_number.setText(Integer.parseInt(bean.getActivity().getAllcount()) - Integer.parseInt(bean.getActivity().getSigncount()) + " 名");
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
                String str = sdf.format(new java.util.Date());
                time = Long.parseLong(TimeChangeUtil.getTimeStamp(str));//系统当前时间戳
                activity_Author.setText(bean.getActivity().getActivityauthor());
                long times = Long.parseLong(bean.getActivity().getActivitystatime());//活动开始时间戳
                long timestop = Long.parseLong(bean.getActivity().getActivityendtime());//活动结束时间戳
                long countstoptime = (timestop - time) * 1000;
                countdownTime = (times - time) * 1000;
                if (bean.getActivity().getCanOrderStatus() != 0 || bean.getOrder().getStatus() == 1) {
                    if (bean.getActivity().getCircle().equals("1")) {
                        if (bean.getOrder().getStatus() == 0) {
                            appointment_button.setText("立即报名");
                            appointment_button.setBackgroundResource(R.drawable.shape_order_corner);
                        } else if (bean.getOrder().getStatus() == 1) {
                            appointment_button.setText("已报名");
                            appointment_button.setEnabled(false);
                            appointment_button.setBackgroundResource(R.drawable.shape_order2_corner);
                        }
                    } else if (bean.getActivity().getCircle().equals("2")) {
                        if (bean.getActivity().getInCir() == 1) {
                            if (bean.getOrder().getStatus() == 0) {
                                appointment_button.setText("立即报名");
                                appointment_button.setBackgroundResource(R.drawable.shape_order_corner);
                            } else if (bean.getOrder().getStatus() == 1) {
                                appointment_button.setText("已报名");
                                appointment_button.setEnabled(false);
                                appointment_button.setBackgroundResource(R.drawable.shape_order2_corner);
                            }

                        } else if (bean.getActivity().getInCir() == 0) {
                            appointment_button.setText("限圈内报名");
                            appointment_button.setEnabled(false);
                            appointment_button.setBackgroundResource(R.drawable.shape_order2_corner);
                        }
                    }
                } else {
                    appointment_button.setText("暂无名额");
                    appointment_button.setEnabled(false);
                    appointment_button.setBackgroundResource(R.drawable.shape_order2_corner);
                }
                if (countstoptime <= 0) {
                    appointment_button.setText("活动已结束");
                    appointment_button.setEnabled(false);
                    xiahua.setVisibility(View.GONE);
                    shengyu.setVisibility(View.GONE);
                    appointment_button.setBackgroundResource(R.drawable.shape_order2_corner);
                }
                if (timer != null) {
                    timer.cancel();
                }
                timer = new CountDownTimer(countdownTime, 1) {
                    @Override
                    public void onTick(long millisUntilFinished) {
                        mDisplayDays = (int) ((millisUntilFinished / 1000) / 86400);
                        mDisplayHours = (int) (((millisUntilFinished / 1000) - (mDisplayDays * 86400)) / 3600);
                        mDisplayMinutes = (int) (((millisUntilFinished / 1000) - ((mDisplayDays * 86400) + (mDisplayHours * 3600))) / 60);
                        mDisplaySeconds = (int) ((millisUntilFinished / 1000) % 60);
                        Days = "" + mDisplayDays;
                        Hours = "" + mDisplayHours;
                        Minutes = "" + mDisplayMinutes;
                        Seconds = "" + mDisplaySeconds;
                        if (mDisplayDays < 10) {
                            Days = "0" + mDisplayDays;
                        }
                        if (mDisplayHours < 10) {
                            Hours = "0" + mDisplayHours;
                        }
                        if (mDisplayMinutes < 10) {
                            Minutes = "0" + mDisplayMinutes;
                        }
                        if (mDisplaySeconds < 10) {
                            Seconds = "0" + mDisplaySeconds;
                        }
                        The_countdown.setText(Days + "天 " + Hours + "时 " + Minutes + "分 " + Seconds + "秒");
                    }

                    @Override
                    public void onFinish() {
                        The_countdown.setText("00天 00时 00分 00秒");
                        The_countdown.setVisibility(View.GONE);
                    }
                }.start();
                loadView.setVisibility(View.GONE);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                Toast.makeText(BookingDetailsPage.this, ex.getMessage() + "错误", Toast.LENGTH_SHORT).show();
            }
        });
    }

    private void showPopupWindow() {
        //设置contentView
        View contentView = LayoutInflater.from(BookingDetailsPage.this).inflate(R.layout.appointment_pay_popwindow_page, null);
        mPopWindow = new PopupWindow(contentView,
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
        mPopWindow.setContentView(contentView);
        payButton = (Button) contentView.findViewById(R.id.pay_button);
        zhifubao = (ImageView) contentView.findViewById(R.id.zhifubao);
        weixin = (ImageView) contentView.findViewById(R.id.weixin);
        money = (TextView) contentView.findViewById(R.id.money);
        zfb = (RelativeLayout) contentView.findViewById(R.id.zfb);
        wx = (RelativeLayout) contentView.findViewById(R.id.wx);
        money.setText("¥" + bean.getActivity().getActivityprice());
        zfb.setOnClickListener(this);
        wx.setOnClickListener(this);
        payButton.setOnClickListener(this);
        //设置各个控件的点击响应

        //显示PopupWindow
        View rootview = LayoutInflater.from(BookingDetailsPage.this).inflate(R.layout.booking_detailspage, null);
        showPopmenu(rootview);
    }

    private void showPopmenu(View rootview) {
        mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1f;
                getWindow().setAttributes(lp);
            }
        });
        // 显示窗口位置
        mPopWindow.showAtLocation(rootview, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        // 设置layout在PopupWindow中显示的位置
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = 0.4f;
        getWindow().setAttributes(lp);
    }

    /**
     * 调用拨号界面
     *
     * @param tel 电话号码
     */
    private void call(String tel) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + tel));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
    }

    int positions = 0;//区分支付宝支付和微信支付

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.action_return:
                finish();
                break;
            case R.id.share://活动分享
                UMWeb web = new UMWeb(AppUrl.URL + "index.php/ban/index/activity.html?id="+activityId);
                String ImageUrl="";
                if (bean.getActivity().getActivityimgurl() != null && !bean.getActivity().getActivityimgurl().equals("")) {
                    String Url = bean.getActivity().getActivityimgurl();
                    ImageUrl = Url.substring(1, Url.indexOf("|"));
                }
                UMImage image = new UMImage(BookingDetailsPage.this, AppUrl.URL + ImageUrl);//资源文件
                UMImage thumb = new UMImage(this, AppUrl.URL + ImageUrl);
                image.setThumb(thumb);
                web.setThumb(thumb);  //缩略图
                web.setTitle(bean.getActivity().getActivitytitle());//标题
                web.setDescription(bean.getActivity().getActivitydescribe());//描述

                //带面板文本分享
                new ShareAction(BookingDetailsPage.this)
                        .withMedia(web)
                        .setDisplayList(SHARE_MEDIA.WEIXIN_CIRCLE,SHARE_MEDIA.WEIXIN ,SHARE_MEDIA.SINA, SHARE_MEDIA.QQ)
                        .setCallback(shareListener)
                        .open();
                break;
            case R.id.best:
                if (consumerId != null && !consumerId.equals("")) {
                    String urls = AppUrl.URLS + AppUrl.LikeUrl;
                    Map<String, String> maps = new HashMap<>();
                    maps.put("likeTid", "4");
                    maps.put("likeUid", consumerId);
                    maps.put("likeFid", bean.getActivity().getActivityid());
                    XUtils.Get(urls, maps, new MyCallBack<String>() {
                        @Override
                        public void onSuccess(String result) {
                            super.onSuccess(result);

                            JSONObject jsonObject = null;
                            try {
                                jsonObject = new JSONObject(result);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            String code = jsonObject.optString("code");
                            if (code.equals("8400") || code.equals("8100")) {
                                Drawable rightDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.praise, null);
                                rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
                                best.setCompoundDrawables(rightDrawable, null, null, null);
                                best.setText(Integer.parseInt(best.getText().toString()) + 1 + "");
                            } else if (code.equals("8000")) {
                                Drawable rightDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.praise_w, null);
                                rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
                                best.setCompoundDrawables(rightDrawable, null, null, null);
                                best.setText(Integer.parseInt(best.getText().toString()) - 1 + "");
                            }
                        }

                        @Override
                        public void onError(Throwable ex, boolean isOnCallback) {
                            super.onError(ex, isOnCallback);
                            Toast.makeText(BookingDetailsPage.this, "点赞错误", Toast.LENGTH_SHORT).show();
                        }

                        @Override
                        public void onFinished() {
                            super.onFinished();
                        }
                    });
                } else {
                    Toast.makeText(BookingDetailsPage.this, "用户未登录,请登录后点赞", Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(BookingDetailsPage.this, WxLoginPage.class));
                    overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                }
                break;
            case R.id.activity_Place:
                call(bean.getStore().getStoretel());//拨打门店电话
                break;
            case R.id.zfb:
                positions = 1;
                zhifubao.setImageResource(R.drawable.check);
                weixin.setImageResource(R.drawable.no_check);
                break;
            case R.id.wx:
                positions = 0;
                weixin.setImageResource(R.drawable.check);
                zhifubao.setImageResource(R.drawable.no_check);
                break;
            case R.id.pay_button:
                if (positions == 1) {
                    Toast.makeText(this, "支付宝支付正在开发中", Toast.LENGTH_SHORT).show();
                } else if (positions == 0) {
                    if (mPopWindow != null && mPopWindow.isShowing()) {
                        mPopWindow.dismiss();
                    }
                    requestPay();
                }
                break;
            case R.id.appointment_button://报名报名
                if (consumerId != null && !consumerId.equals("")) {
                    if (ApplicationUtils.getInstance().loginBean != null && ApplicationUtils.getInstance().loginBean.getConsumertel() == null) {
                        Toast.makeText(BookingDetailsPage.this, "请先绑定手机号", Toast.LENGTH_SHORT).show();
                        Intent intent1 = new Intent(BookingDetailsPage.this, BindingPhonePage.class);
                        startActivity(intent1);
                        overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                        return;
                    }
                    if (bean.getActivity().getOrderStatus() == 0) {
                        showPopupWindow();
                        return;
                    }
                    String url = AppUrl.URLS + AppUrl.CancelReservation;
                    Map<String, String> map = new HashMap<>();
                    map.put("activityId", activityId);
                    map.put("consumerId", consumerId);
                    map.put("statics", bean.getActivity().getStatics().toString());
                    XUtils.Get(url, map, new MyCallBack<String>() {
                        @Override
                        public void onSuccess(String result) {
                            super.onSuccess(result);
                            JSONObject jsonObject = null;
                            try {
                                jsonObject = new JSONObject(result);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            String results = jsonObject.optString("result");
                            String code = jsonObject.optString("code");
                            if (code.equals("6016")) {
                                Toast.makeText(BookingDetailsPage.this, "你已经报名该活动,不能重复你已经报名该活动", Toast.LENGTH_SHORT).show();
                            } else if (results.equals("true")) {
                                Intent intent = new Intent();
                                intent.putExtra("consumerId", consumerId);
                                intent.putExtra("activityId", activityId);
                                intent.putExtra("time", bean.getActivity().getActivityendtime());
                                intent.putExtra("address", bean.getActivity().getActivityplace());
                                intent.setClass(BookingDetailsPage.this, SignUpSuccessPage.class);
                                startActivity(intent);
                                overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                                Toast.makeText(BookingDetailsPage.this, "报名成功", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(BookingDetailsPage.this, code + "报名失败", Toast.LENGTH_SHORT).show();
                            }
                        }

                        @Override
                        public void onError(Throwable ex, boolean isOnCallback) {
                            super.onError(ex, isOnCallback);
                        }
                    });
                } else {
                    appointment_button.setText("立即报名");
                    Toast.makeText(BookingDetailsPage.this, "用户未登录,请登录报名", Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(BookingDetailsPage.this, WxLoginPage.class));
                    overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                }
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {

        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    private void requestPay() {
        String url = AppUrl.URL + AppUrl.payUrl;
        Map<String, String> map = new HashMap<>();
        // 微信
        map.put("consumerId", ApplicationUtils.getInstance().loginBean.getConsumerid());
        map.put("activityId", bean.getActivity().getActivityid());
        map.put("body", bean.getActivity().getActivitytitle());
        XUtils.Get(url, map, new MyCallBack<String>() {
            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                Log.e("----", result);
                JSONObject obj = null;
                try {
                    obj = new JSONObject(result);
                    // 微信支付回调
                    setWeChat(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);

            }

            @Override
            public void onFinished() {
                super.onFinished();
            }
        });
    }

    /**
     * 微信支付
     */
    private void setWeChat(JSONObject obj) {
        mIwxapi = WXAPIFactory.createWXAPI(this, obj.optString("appid"));
        mIwxapi.registerApp(obj.optString("appid"));// 将应用注册到微信
        if (mIwxapi != null && mIwxapi.isWXAppInstalled()) {// 判断用户有没有安装微信
            PayReq req = new PayReq();
            req.appId = obj.optString("appid");
            req.partnerId = obj.optString("partnerid");
            req.prepayId = obj.optString("prepayid");
            req.nonceStr = obj.optString("noncestr");
            req.timeStamp = obj.optString("timestamp");
            req.packageValue = obj.optString("package");
            req.sign = obj.optString("sign");
            // req.extData = "app data";// 可选
            mIwxapi.sendReq(req);
        } else {
            Toast.makeText(this, "用户未安装微信", Toast.LENGTH_SHORT).show();
            return;
        }
    }

    private UMShareListener shareListener = new UMShareListener() {
        /**
         * @descrption 分享开始的回调
         * @param platform 平台类型
         */
        @Override
        public void onStart(SHARE_MEDIA platform) {

        }

        /**
         * @descrption 分享成功的回调
         * @param platform 平台类型
         */
        @Override
        public void onResult(SHARE_MEDIA platform) {
            Toast.makeText(BookingDetailsPage.this, "分享成功", Toast.LENGTH_LONG).show();
        }

        /**
         * @descrption 分享失败的回调
         * @param platform 平台类型
         * @param t 错误原因
         */
        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
            Toast.makeText(BookingDetailsPage.this, "分享失败" + t.getMessage(), Toast.LENGTH_LONG).show();
        }

        /**
         * @descrption 分享取消的回调
         * @param platform 平台类型
         */
        @Override
        public void onCancel(SHARE_MEDIA platform) {
            Toast.makeText(BookingDetailsPage.this, "分享取消", Toast.LENGTH_LONG).show();

        }
    };

    /**
     * 分享是否同意的回调
     *
     * @param requestCode
     * @param permissions
     * @param grantResults
     */
    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {

    }
}
